package mezzo;
/**
 * JOAQUÍN RAMÓN ANTÚNEZ SÁNCHEZ
 * 16 de septiembre de 2014
 */

import java.util.HashMap;

@SuppressWarnings({"unchecked", "rawtypes"})
public class CD extends DefaultMezzo{

	
	public CD() {
		super();
		this.data = new HashMap();
		this.data.put("titulo", "");
		this.data.put("titulo_interpretacion", "");
		this.data.put("volumenes", new Integer(1));
		this.data.put("id_etiqueta", new Integer(0));
		this.data.put("coleccion", "");
		this.data.put("numero_de_serie", "");
		this.data.put("edicion", new Integer(0));
		this.data.put("horas", new Integer(0));
		this.data.put("minutos", new Integer(0));
		this.data.put("segundos", new Integer(0));
		this.data.put("generos", new Integer(0));
		
	}
	
	public void clear(){		
		super.clear();
		this.data.put("volumenes", new Integer(1));
	}
	
	
	public String getTitulo(){  return this.data.get("titulo").toString(); }
	public String getSubtitulo(){  return this.data.get("titulo_interpretacion").toString(); }
	public String getColeccion(){  return this.data.get("coleccion").toString(); }
	public String getSerie(){  return this.data.get("numero_de_serie").toString(); }
	public int getVolumenes(){ return Integer.parseInt( this.data.get("volumenes").toString() ); }
	public Decca getEtiqueta(){ 
		Decca d = new Decca();
		d.find( this.data.get("id_etiqueta") );
		return d;
	}
	public int getEdicion(){ return Integer.parseInt( this.data.get("edicion").toString() ); }
	public String getTiempo(){
		
		int h, m, s;
		h = Integer.parseInt( this.data.get("horas").toString() );
		m = Integer.parseInt( this.data.get("minutos").toString() );
		s = Integer.parseInt( this.data.get("segundos").toString() );
		if( m == 0 && h == 0 && s == 0 )
			return new String("");
		else
			if( h!= 0 )
				return String.format("%d.%02d:%02d", h, m, s);
			else
				return String.format("%02d:%02d", m, s);
		
	}
	
	public int getGeneros(){ return Integer.parseInt( this.data.get("generos").toString() ); }
	
	public void setTitulo(String value){ this.data.put("titulo", value.trim()); }
	public void setSubtitulo(String value){ this.data.put("titulo_interpretacion", value.trim()); }
	public void setColeccion(String value){ 
		this.data.put("coleccion", value.trim().toUpperCase()); 
		}
	public void setSerie(String value){ this.data.put("numero_de_serie", value.trim()); }	
	public void setVolumenes(int value){ this.data.put("volumenes", value); }
	public void setEdicion(int value){ this.data.put("edicion", value); }
	public void setEtiqueta(Decca value){ 
		this.data.put("id_etiqueta", value.get()); 
	}
	public void setGeneros(int value){ this.data.put("generos", value); }
	// tiempo ---------------------------------------------------------------------
	
	
	@Override
	public String toString(){
		StringBuffer s = new StringBuffer( this.getTitulo() );
		if( !this.getSubtitulo().isEmpty())
			s.append(  String.format(" (%s)", this.getSubtitulo()) );
		s.append("; " + this.getVolumenes() + " CD" );
		
		return s.toString();
	}	
}
